I am playing videos that are in my app bundle.They are playing correctly.However, when I call to dismiss the AVPlayerViewController, it visibly is removed from the view hierarchy but, if I turn off the iOS device and turn it back on again, on the lock screen there is a media control showing that video and a 'play' button.If you touch play you only get the audio and no video.My problem is I don't understand why the 'dismiss' is not completely 'killing' the player when I'm done with it.NOTE: The follow code works perfectly in iOS 13 devices, however any device running previous iOS versions, the error appears as stated. This is blocking me from submitting my app, please can someone advise on how to solve this? Here is the presentation code:
internal func play(FileName filename: String, FileType type: String)
{
if self.isAlreadyPlaying == YES
{
killVideoPlayer()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5, execute: { self.play(FileName: filename, FileType: type) })
return
}
let audioSession = AVAudioSession.sharedInstance()
do
{
try audioSession.setCategory(AVAudioSession.Category.playback, mode: .moviePlayback, options: [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP])
try audioSession.setActive(true)
}
catch
{
print("Audio session failed")
}
let path = Bundle.main.path(forResource: filename, ofType: type)
let url = NSURL(fileURLWithPath: path!)
let player = AVPlayer(url: url as URL)
NotificationCenter.default.addObserver(self,
selector: #selector(PBFMenuSystemFloatingButtonsViewController.didFinishPlaying(notification:)),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,
object: player.currentItem)
self.playerController = AVPlayerViewController()
self.menuWindow.videoPlayer = self.playerController
self.playerController?.player = player
self.playerController?.allowsPictureInPicturePlayback = true
self.playerController?.showsPlaybackControls = YES
self.playerController?.delegate = self
self.playerController?.exitsFullScreenWhenPlaybackEnds = YES
self.isAlreadyPlaying = YES
self.present(self.playerController!, animated: true, completion : { self.playerController?.player?.play() })
}
Here is the dismissal code:
private func killVideoPlayer()
{
self.isAlreadyPlaying = NO
self.playerController?.player?.pause()
self.playerController?.player = nil
let audioSession = AVAudioSession.sharedInstance()
do
{
try audioSession.setActive(false, options: .notifyOthersOnDeactivation)
try audioSession.setCategory(.soloAmbient)
}
catch
{
print("Audio session failed")
}
self.playerController?.dismiss(animated: YES, completion: { self.playerController = nil })
}
And here's what's remaining in the systemwide media player that is shown on the lock screen / control centre:
Post
Replies
Boosts
Views
Activity
Hi
I have an iOS app that is in the App Store.
I've just downloaded Xcode 12 and iOS 14 Beta 1, which I've installed on my Ipad Pro 12.9" Gen 1.
In both the Simulator and on the real device, on iOS 14 the launch screen is just black.
However, the EXACT same code, run in Xcode 11.5 in the iOS 13 simulator (and the app in the App Store) show the launch screen storyboard just fine.
The same code is being opened in both versions of Xcode and no changes are made. I can go back and forth between Xcode versions and the same code works on iOS 13 simulator and breaks on iOS 14 simulator / iPad.
There are no errors. No build problems. No warnings.
Everything is the same release code that is working in the store, but when ran in Xcode 12 and on iOS 14 Beta 1, the launch screen is totally black.
Any help please? I need to ensure compatibility.
Thanks
I have a killer app idea, but I need to know if it's possible to watch a TV or PC monitor whilst wearing Vision Pro without any latency.
i.e. Imagine playing a console game or PC game but having custom app overlays in 3D spatial world that you can still look at and interact with whilst still watching/playing the game on the 'real' monitor/tv.